from django.shortcuts import render
from django.views.decorators.http import require_http_methods
from django.contrib.auth import get_user_model,login,logout
User = get_user_model()
# Create your views here.
def index(request):
    return render(request, "Sales_index.html")

def Sales_products(request):
    return render(request, "Sales_products.html")

def Sales_information(request):
    return render(request,"Sales_information.html")

def Sales_base(request):
    return render(request, "Sales_base.html")

def Sales_aboutUs(request):
    return render(request, "Sales_aboutUs.html")

def Sales_contactUs(request):
    return render(request, "Sales_contactUs.html")

def Sales_admin(request):
    return render(request, "Sales_manage/Sales_admin.html")

def Sales_join(request):
    return render(request, "Sales_sellerJoin.html")

def Sales_seller(request):
    return render(request, "Sales_manage/Sales_seller.html")

# TODO 登录账号
@require_http_methods(['GET', 'POST'])
def Sales_login(request):
    if request.method == "GET":
        return render(request, "Sales_manage/Sales_login.html")
    if request.method == "POST":
        role = request.POST.get('role')
        account = request.POST.get('account')
        username = request.POST.get('username')
        password = request.POST.get('password')

        email = request.POST.get('email')
        user = User.objects.filter(email=email).first()
        if role == "admin":
            return render(request, "Sales_manage/Sales_admin.html")
        else:
            print(role,request)
            return render(request, "Sales_manage/Sales_seller.html")

def Sales_detail(request):
    return render(request,"Sales_detail.html")